
//
//  ZXBoutiqueViewModel.m
//  XiMaFM
//
//  Created by fanzhuxian on 2017/9/6.
//  Copyright © 2017年 hcios. All rights reserved.
//

#import "ZXBoutiqueViewModel.h"

#import "ZXBoutiqueModel.h"

#import "ZxHomePageNetManager.h"

@implementation ZXBoutiqueViewModel

- (void)getDataCompletionHandle:(void (^)(NSError *))completed {
    
    self.dataTask = [ZxHomePageNetManager getAnchorPageCompletionHandle:^(ZXBoutiqueModel * responseObject, NSError *error) {
        self.boutiqueModel = responseObject;
        self.categoryContentsArr = responseObject.categoryContents.list;
        self.section = _categoryContentsArr.count;
        completed(error);
    }];
}

#pragma mark - 推荐内容


- (id)modelForSection:(NSInteger)section {
    
    return self.boutiqueModel.categoryContents;
}

- (NSString *)mainTitleForSection:(NSInteger)section {
    return self.boutiqueModel.categoryContents.list[section].title;
    
}

- (BOOL)hasMoreForSection:(NSInteger)section {
    
    return self.boutiqueModel.categoryContents.list[section].hasMore;
    
}

#pragma mark - 给FindPutCell的属性方法
#pragma mark  section是组数, index是按钮下标( 或者行标号)--- DiscoveryCell,SpecialCell三者共用cover title track(subtitle)方法
// 图
// 热门推荐 列表(外层需要HotR_List_List* 读取数组中的对象)
- (NSURL *)coverURLForSection:(NSInteger)section index:(NSInteger)index {
    NSString *path = nil;
    
    path =  self.boutiqueModel.categoryContents.list[section].list[index].albumCoverUrl290;
    
    return [NSURL URLWithString:path];
}
- (NSString *)titleForSection:(NSInteger)section index:(NSInteger)index {
    
    return self.boutiqueModel.categoryContents.list[section].list[index].title;
}
//评分
-(NSInteger)scoreForSection:(NSInteger)section index:(NSInteger)index {
    return self.boutiqueModel.categoryContents.list[section].list[index].score;
}
//评论
-(NSInteger)commentsCountForSection:(NSInteger)section index:(NSInteger)index {
    return self.boutiqueModel.categoryContents.list[section].list[index].commentsCount;
    
}
//价格
-(NSInteger)priceForSection:(NSInteger)section index:(NSInteger)index {
    return self.boutiqueModel.categoryContents.list[section].list[index].price;
    
}
//会员价格
-(NSString *)displayVipPriceForSection:(NSInteger)section index:(NSInteger)index {
    return self.boutiqueModel.categoryContents.list[section].list[index].displayVipPrice;
    
}

- (NSString *)trackTitleForSection:(NSInteger)section index:(NSInteger)index {
    
    return self.boutiqueModel.categoryContents.list[section].list[index].trackTitle;
    
}
- (NSInteger)albumIdForSection:(NSInteger)section index:(NSInteger)index {
    
    return self.boutiqueModel.categoryContents.list[section].list[index].albumId;
    
}

// 集数  -- 跳转页tableView的row
- (NSInteger)tracksForSection:(NSInteger)section index:(NSInteger)index {
    
    return self.boutiqueModel.categoryContents.list[section].list[index].tracks;
    
}

- (NSArray *)hotListsModelForSection:(NSInteger)section {
    return self.boutiqueModel.categoryContents.list;
}



#pragma mark - 跳转需要值
- (NSInteger)categoryIdForSection:(NSInteger)section {
    
    return self.boutiqueModel.categoryContents.list[section].moduleType;
    
}

- (NSString *)contentTypeForSection:(NSInteger)section {
    return self.boutiqueModel.categoryContents.list[section].contentType;
    
}

#pragma mark - 头部滚动视图
/** 滚动展示栏的图片数量 */
- (NSInteger)focusImgNumber {
    return self.boutiqueModel.focusImages.list.count;
}

/** 滚动展示栏的图片地址 */
- (NSURL *)focusImgURLForIndex:(NSInteger)index {
    NSString *path = self.boutiqueModel.focusImages.list[index].pic;
    return [NSURL URLWithString:path];
    
}


#pragma mark -
- (NSInteger)categoryContentsCount:(NSInteger)section{
    ZXCategoryContent * categortyCount = self.boutiqueModel.categoryContents;
    return categortyCount.list[section].list.count ;
}

@end
